package com.fz.controller;

import com.fz.Mapper.BookMapper;
import com.fz.mybatis.MyHelper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by webrx on 2017-09-06.
 */
@Controller
@RequestMapping("/yu")
public class BookTest {
    MyHelper mh=new MyHelper();
    SqlSession s=mh.getSession();
    BookMapper bo=s.getMapper(BookMapper.class);

    @RequestMapping("/book")
    public String book(Model model){
    model.addAttribute("shu",bo.queryall());
    return "/user/book";
    }

    @RequestMapping("/delete/{id}")
    public String book(@PathVariable("id") int id){
        bo.delete(id);
        s.commit();
        return "redirect:/yu/book";
    }
}
